The present invention generally relates to video coding and decoding and, more particularly, to a system and a method for context-based adaptive binary arithmetic coding (CABAC) and decoding.
Context-based adaptive arithmetic coding (CABAC) is an entropy coding scheme specified in the standard, H.264/AVC MAIN and HIGH profiles. FIG. 1 is a schematic diagram of a structure of an exemplary bit stream 10 such as an H.264/AVC High profile level 4.1 bit stream under the H.264 standard. Referring to FIG. 1, the bit stream 10 may include a plurality of data slices (not numbered), wherein each of the data slices may include a slice header layer 11 and a slice data layer 12. The slice data layer 12 may include a plurality of macro blocks (MBs) 13, wherein each of the MBs 13 may include one or more syntax element (SE) 14. Each of the SE 14 has a value and may further include one or more bin 15, which in turn is a binary value, i.e., either 0 or 1.
Algorithms for CABAC encoding and decoding are briefly discussed below. FIG. 2A is a flow diagram illustrating an algorithm for CABAC encoding. Referring to FIG. 2A, before encoding the first SE in a slice data layer, a number of 459 sets of context models (CMs) are initialized at step 20. Each of the CMs includes a 6-bit probability state index (pStateIdx) and a 1-bit most probability symbol (valMPS) that has a bin value. To encode an SE, four major steps including binarization, context model selection, binary arithmetic encoding and bit-generation may be required. At step 21, an SE is converted by its value into a bin string, which is composed of one or more binary bit. Next, one of the 459 sets of CMs may be selected for each bin in the bin string based on a context model index (ctxIdx) at step 22. In response to a selected CM, a binary arithmetic coder (BAC) may encode a bin at step 23. After encoding the bin, the BAC performs renormalization and updates the selected CM at step 24. Subsequently, encoded bit data may be generated at step 25.
FIG. 2B is a flow diagram illustrating an algorithm for CABAC decoding. Referring to FIG. 2B, before decoding bin(s) of an SE, the 459 sets of CMs are initialized at step 20. To decode each bin of an SE, three major steps including context model selection, binary arithmetic decoding and de-binarization may be required. At step 22, a CM for a bin is selected based on a ctxIdx, which may be a constant or a value determined by previously decoded bins or information from neighbor blocks. In response to a selected CM, a binary arithmetic decoder (BAD) may decode the bin at step 26. Furthermore, the BAD updates the selected CM at step 24 and outputs a value of the bin. The CM update and bin value output steps are repeated until a bin string is generated for the SE. Subsequently, the decoded bin string is de-binarized to generate the value of the SE.
From FIGS. 2A and 2B, it may be found that some processes such as CM initialization and CM selection may be common to the coding and decoding schemes. It may therefore be desirable to have a system that integrates the CABAC encoding and decoding schemes. Furthermore, it may also be desirable to have a system that processes CABAC encoding and decoding in a pipeline architecture.